package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: TaskStagesController
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-18
 * @Version: 1.0
 * Table: pear_task_stages
 * Comment:
 * 任务列表表
 */
@RestController
@RequestMapping(value = "/task_stages")
public class TaskStagesController extends TaskStagesCustomController {
    static {
        addRequestClass("task_stages", "add", "taskStagesController", TaskStagesController.class, TaskStagesAddRequest.class);
        addRequestClass("task_stages", "add_encrypt", "taskStagesController", TaskStagesController.class, TaskStagesAddRequest.class);

        addRequestClass("task_stages", "update", "taskStagesController", TaskStagesController.class, TaskStagesUpdateRequest.class);
        addRequestClass("task_stages", "update_encrypt", "taskStagesController", TaskStagesController.class, TaskStagesUpdateRequest.class);

        addRequestClass("task_stages", "delete", "taskStagesController", TaskStagesController.class, TaskStagesDeleteRequest.class);
        addRequestClass("task_stages", "delete_encrypt", "taskStagesController", TaskStagesController.class, TaskStagesDeleteRequest.class);

        addRequestClass("task_stages", "query", "taskStagesController", TaskStagesController.class, TaskStagesQueryRequest.class);
        addRequestClass("task_stages", "query_encrypt", "taskStagesController", TaskStagesController.class, TaskStagesQueryRequest.class);

        addRequestClass("task_stages", "list", "taskStagesController", TaskStagesController.class, TaskStagesQueryRequest.class);
        addRequestClass("task_stages", "list_encrypt", "taskStagesController", TaskStagesController.class, TaskStagesQueryRequest.class);

        addRequestClass("task_stages", "count", "taskStagesController", TaskStagesController.class, TaskStagesQueryRequest.class);
        addRequestClass("task_stages", "count_encrypt", "taskStagesController", TaskStagesController.class, TaskStagesQueryRequest.class);

        addRequestClass("task_stages", "stat", "taskStagesController", TaskStagesController.class, TaskStagesQueryRequest.class);
        addRequestClass("task_stages", "stat_encrypt", "taskStagesController", TaskStagesController.class, TaskStagesQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addTaskStages(@MixRequestBody TaskStagesAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_stages", "add", request, callFromEncrypt);
        return super.addTaskStages(request);
    }

    @PostMapping("/add_encrypt")
    public String addTaskStagesEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskStagesAddRequest request = (TaskStagesAddRequest) super.decrypt("task_stages", "add_encrypt", strRequest, TaskStagesAddRequest.class);
        Integer result = addTaskStages(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateTaskStages(@MixRequestBody TaskStagesUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_stages", "update", request, callFromEncrypt);
        return super.updateTaskStages(request);
    }

    @PostMapping("/update_encrypt")
    public String updateTaskStagesEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskStagesUpdateRequest request = (TaskStagesUpdateRequest) super.decrypt("task_stages", "update_encrypt", strRequest, TaskStagesUpdateRequest.class);
        Integer result = updateTaskStages(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteTaskStages(@MixRequestBody TaskStagesDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_stages", "delete", request, callFromEncrypt);
        return super.deleteTaskStages(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteTaskStagesEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskStagesDeleteRequest request = (TaskStagesDeleteRequest) super.decrypt("task_stages", "delete_encrypt", strRequest, TaskStagesDeleteRequest.class);
        Integer result = deleteTaskStages(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public TaskStagesQueryResponse queryTaskStages(@MixRequestBody TaskStagesQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("task_stages", "query", request, callFromEncrypt);
      return super.queryTaskStages(request);
    }

    @PostMapping("/query_encrypt")
    public String queryTaskStagesEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskStagesQueryRequest request = (TaskStagesQueryRequest) super.decrypt("task_stages", "query_encrypt", strRequest, TaskStagesQueryRequest.class);
        TaskStagesQueryResponse result = queryTaskStages(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<TaskStagesQueryResponse> listTaskStages(@MixRequestBody TaskStagesQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_stages", "list", request, callFromEncrypt);
        if (super.needTotal("task_stages", "list", request)) {
            super.setTotal("task_stages", "list", request, super.countTaskStages(request));
        }
        return super.listTaskStages(request);
    }

    @PostMapping("/list_encrypt")
    public String listTaskStagesEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskStagesQueryRequest request = (TaskStagesQueryRequest) super.decrypt("task_stages", "list_encrypt", strRequest, TaskStagesQueryRequest.class);
        List<TaskStagesQueryResponse> result = listTaskStages(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countTaskStages(@MixRequestBody TaskStagesQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("task_stages", "count", request, callFromEncrypt);
      return super.countTaskStages(request);
    }


    @PostMapping("/count_encrypt")
    public String countTaskStagesEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskStagesQueryRequest request = (TaskStagesQueryRequest) super.decrypt("task_stages", "count_encrypt", strRequest, TaskStagesQueryRequest.class);
        Integer result = countTaskStages(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statTaskStages(@MixRequestBody TaskStagesQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_stages", "stat", request, callFromEncrypt);
        return super.statTaskStages(request);
    }

    @PostMapping("/stat_encrypt")
    public String statTaskStagesEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskStagesQueryRequest request = (TaskStagesQueryRequest) super.decrypt("task_stages", "stat_encrypt", strRequest, TaskStagesQueryRequest.class);
        BaseStatResponse result = statTaskStages(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


}
